﻿@section header
{
    <link href="~/Themes/RongJi/Style/base/css/account.css" rel="stylesheet">
}
@section title
{
    修改密码
}
@model RiderShop.Mobile.Modle.CustomerModel
<div id="equalize">
    <div class="col-right">
        <div class="wrapper-right">
            <dl class="section">
                <dd class="sectionC">
                    <form action="~/Customer/ResetPassword" id="resetPwdForm" method="post">
                        <div class="item">
                            <label>新密码：</label>
                            <input type="password" id="newPwd" name="newPwd" value="" class="cmnTInput" placeholder="请输入新密码">
                            <span class="require">*</span>
                        </div>
                        <div class="item">
                            <label>确认密码：</label>
                            <input type="password" id="txtRePassword" name="RePassword" class="cmnTInput" placeholder="请输入确认密码" />
                            <span class="require">*</span>
                        </div>
                        @if (Model.Result != null && !Model.Result.Status && Model.Result.ErrorMessage != null)
                        {
                            <div class="item">
                                <label></label>
                                <span class="err_msg">@Model.Result.ErrorMessage</span>
                            </div>
                        }
                        <div class="btnGroup">
                            <input type="hidden" id="forgetpwd" name="forgetpwd" value='@Request.QueryString["forgetpwd"]' />
                            <input type="submit" value="保存" id="btnSubmit" class="rjbtn rjbtnGreen">
                        </div>
                    </form>
                </dd>
            </dl>
        </div>
    </div>
</div>
@section footer
{
    <script type="text/javascript">
        $(function () {
            //重置密码表单验证
            $("#resetPwdForm").validate({
                rules: {
                    newPwd: {
                        required: true,
                        minlength: 6,
                        maxlength: 20
                    },
                    RePassword: {
                        required: true,
                        minlength: 6,
                        maxlength: 20,
                        equalTo: "#newPwd"
                    }
                },
                submitHandler: function (form) {
                    resetPwd();
                }
            });

            function resetPwd() {
                if ($('#newPwd').val() == "") {
                    KevinShop.MessageBox.Alert("请输入新密码!");
                    return false;
                }
                if ($('#txtRePassword').val() == "") {
                    KevinShop.MessageBox.Alert("请输入确认密码!");
                    return false;
                }
                if ($('#newPwd').val() != $('#txtRePassword').val()) {
                    KevinShop.MessageBox.Alert("请确认新密码和确认密码是一样的!");
                    return false;
                }
                postdata = "{'forgetpwd':'" + $("#forgetpwd").val() + "','newPwd':'" + $("#newPwd").val() + "'}"
                KevinShop.Common.Ajax.Post(document.forms["resetPwdForm"].action, postdata, function (data) {
                    if (data) {
                        isCodeSended = false;
                        KevinShop.MessageBox.Alert(data);
                    }
                    else {
                        KevinShop.MessageBox.Success("密码重置成功，请登录！");
                        setTimeout(function () {
                            window.location.href = "login";
                        }, 1500);

                    }
                });
                return false;
            }
        });
    </script>
}